FlyTalk.views.HelpOutView = Ext.extend(Ext.Panel, {
	id: 'HelpOutView',
	scroll: false,
    indicator: true,
    fullscreen: true,
    layout: 'card', 
	title: 'Help Out',

    initComponent: function () {
		var direction = 'left';
    	this.backButton = new Ext.Button({
			iconCls: 'home',
			iconMask: true,
			handler: this.backButtonTap,
			scope: this
		});
		
		this.notifButton = new Ext.Button({
			ui: 'back',
			text: 'back',
			iconMask: true,
			handler: this.notifButtonTap,
			
			hidden: true,
			scope: this
		});
		
		this.toolbar = new Ext.Toolbar({
			title: 'Help Out',
			doc: 'top',
			layout: 'hbox',
			items: [
			    this.backButton,
				this.notifButton,
				{xtype: 'spacer'},
				//this.composeButton,
			]
		});
		
		
		buttonsGroup2 = new Ext.SegmentedButton({ 
			xtype: 'segmentedbutton',
			//id: 'helpOutTabButtons',
			allowDepress: false,
			items: [{
				text: 'Questions',
				padding: '0 10 0 10',
				//handler: this.backButtonTap,FlyTalk.views.ServicesTabAllView, 
				handler: function () {
					FlyTalk.views.HelpOutView.setActiveItem(FlyTalk.views.HelpOutTabQuestionsView, {type: 'slide', direction: 'right'});	
					direction = 'left';
				},
				pressed: true
			}, {
				text: 'Reviews',
				padding: '0 10 0 10',
				//handler: this.backButtonTap
				handler: function () {
					//FlyTalk.views.HelpOutView.setActiveItem(FlyTalk.views.HelpOutTabReviewView);
					console.log(direction)
					if (direction == 'left'){
						FlyTalk.views.HelpOutView.setActiveItem(FlyTalk.views.HelpOutTabReviewView,{type: 'slide', direction: 'left'});
					} else {
						FlyTalk.views.HelpOutView.setActiveItem(FlyTalk.views.HelpOutTabReviewView,{type: 'slide', direction: 'right'});
					}
					
				},
			}, {
				text: 'Time Estimates',
				//handler: this.backButtonTap
				handler: function () {
					FlyTalk.views.HelpOutView.setActiveItem(FlyTalk.views.HelpOutTabTimeEstView, {type: 'slide', direction: 'left'});
					direction = 'right';
				},
			}]
		});
		
		this.toolbartab = new Ext.Toolbar({
			//title: 'Services',
			doc: 'top',
			layout: 'hbox',
			ui: 'toptab',
			//style: 'background-color: bfbfbf',
			items: [
				{xtype: 'spacer'},
			    buttonsGroup2,
				{xtype: 'spacer'},
		
			]
		});
		
		
			
	
		this.dockedItems = [this.toolbar, this.toolbartab];
		
		Ext.apply(FlyTalk.views, {
				HelpOutTabQuestionsView: new FlyTalk.views.HelpOutTabQuestionsView(),
				HelpOutTabReviewView: new FlyTalk.views.HelpOutTabReviewView(),
				HelpOutTabTimeEstView: new FlyTalk.views.HelpOutTabTimeEstView(),				
        });
           

		this.items = [
			FlyTalk.views.HelpOutTabQuestionsView, 
			FlyTalk.views.HelpOutTabReviewView, 
			FlyTalk.views.HelpOutTabTimeEstView, 
					
		];
		
		FlyTalk.views.HelpOutView.superclass.initComponent.call(this);
        
    },
    
	//home button
    backButtonTap: function () {
    	// restore value
    	FlyTalk.views.HelpOutTabQuestionsView.helpStore.getAt(0).data.text = 'Five People ask:'
		FlyTalk.views.HelpOutTabQuestionsView.list.refresh();
    	
    	FlyTalk.views.HelpOutTabReviewView.helpStore.getAt(0).data.question = 'Can you answer five easy questions about La Italia Restaurant?'
		FlyTalk.views.HelpOutTabReviewView.list.refresh();
    
		
        Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openHome'
        });
    },
	notifButtonTap: function () {
		FlyTalk.views.mainView.setActiveItem(FlyTalk.views.NotificationView, {type: 'slide', direction: 'right'});	
    	// restore value
		// Ext.dispatch({
			// controller: FlyTalk.controllers.dbController,
			// action: 'getNotification',
		// });
    },
});